﻿using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Pyramid.Extentions;

namespace Pyramid.Models
{
	/// <summary>
	/// 收款记录
	/// </summary>
	public class PayeeRecord
	{
		public int Id { get; set; }

		[Display(Name = "收款项目")]
		public int ProjectId { get; set; }

		[Display(Name = "收款金额")]
		public decimal Amount { get; set; }

		[Display(Name = "年份")]
		public int Year { get; set; }

		[Display(Name = "月份")]
		public int Month { get; set; }

		[Display(Name = "收款说明")]
		[MaxLength(200)]
		public string Instruction { get; set; }

		[Display(Name = "付款方编号")]
		public int PayerId { get; set; }

		[Display(Name = "付款方名称")]
		[Required]
		[MaxLength(20)]
		public string PayerName { get; set; }

		[Display(Name = "付款方类型")]
		public int PayerType { get; set; }

		[NotMapped]
		public PayerTypes PayerTypeEnum
		{
			get { return (PayerTypes) PayerType; }
		}

		[NotMapped]
		public string PayerTypeString
		{
			get { return PayerTypeEnum.ToDescription(); }
		}

		[Display(Name = "收款发起人")]
		[Required]
		[MaxLength(20)]
		public string ApplyUserId { get; set; }

		[Display(Name = "发起人姓名")]
		[Required]
		[MaxLength(20)]
		public string ApplyUserName { get; set; }

		[Display(Name = "发起时间")]
		public DateTime ApplyTime { get; set; }

		[Display(Name = "收款账号")]
		public int FinanceAccountId { get; set; }

		[Display(Name = "状态")]
		public int Status { get; set; }

		[NotMapped]
		public PayeeRecordStatus StatusEnum
		{
			get { return (PayeeRecordStatus) Status; }
		}

		[NotMapped]
		public string StatusString
		{
			get { return StatusEnum.ToDescription(); }
		}

		public int? VerifyId { get; set; }

		[ForeignKey("VerifyId")]
		public virtual PayeeVerify Verify { get; set; }

		[ForeignKey("ProjectId")]
		public virtual FinanceProject Project { get; set; }

		[ForeignKey("FinanceAccountId")]
		public virtual FinanceAccount FinanceAccount { get; set; }
	}

	/// <summary>
	/// 收款审核信息
	/// </summary>
	public class PayeeVerify
	{
		public int Id { get; set; }

		[Display(Name = "审核人")]
		[MaxLength(20)]
		[Required]
		public string VerifyUserId { get; set; }

		[Display(Name = "审核时间")]
		public DateTime VerifyTime { get; set; }

		[Display(Name = "财务流水号")]
		[MaxLength(40)]
		[Required]
		public string FinanceNumber { get; set; }

		[Display(Name = "审核备注")]
		[MaxLength(200)]
		public string VerifyRemark { get; set; }

		public int PayeeRecordId { get; set; }
	}
}